<template>

  <div class="news-detail" v-loading="loading" ref="print">
    <el-page-header @back="goBack" content="详情页面" style="font-weight: bold; font-size: 20px"></el-page-header>
    <div class="admin-detail">

      <div class="detail detail-longtext">
        <div class="detail-title">
          标题：
        </div>
        <div class="detail-content">
          {{ map.title }}
        </div>
      </div>
      <div class="detail detail-select">
        <div class="detail-title">
          分类：
        </div>
        <div class="detail-content">
          <e-select-view module="newskind" :value="map.kind" select="id" show="name"></e-select-view>
        </div>
      </div>
      <div class="detail detail-image">
        <div class="detail-title">
          图片：
        </div>
        <div class="detail-content">
          <e-img :src="map.photo" style="max-width:120px" />
        </div>
      </div>
      <div class="detail detail-textuser">
        <div class="detail-title">
          添加人：
        </div>
        <div class="detail-content">
          {{ map.admin }}
        </div>
      </div>
      <div class="detail detail-number">
        <div class="detail-title">
          点击量：
        </div>
        <div class="detail-content">
          {{ map.clicks }}
        </div>
      </div>
      <div class="detail detail-autotime">
        <div class="detail-title">
          添加时间：
        </div>
        <div class="detail-content">
          {{ map.addtime }}
        </div>
      </div>
      <div class="detail detail-editor">
        <div class="detail-title">
          内容：
        </div>
        <div class="detail-content">
          <div v-html="map.content"></div>
        </div>
      </div>
    </div>
    <div class="mt10">
      <el-button style="letter-spacing: 2px; font-weight: bold; font-size: 18px" type="default" class="hidePrint"
        @click="$router.go(-1)">
        返回
      </el-button>
      <el-button
        style="letter-spacing: 2px; font-weight: bold; font-size: 18px;background-color: #659ab1; border-color:#659ab1;"
        type="success" class="hidePrint" @click="$print">
        打印本页
      </el-button>
    </div>
  </div>
</template>

<style type="text/scss" scoped lang="scss">
.news-detail {
  background-color: #fff;
  border-radius: 10px;
  padding: 18px;

  ::v-deep .el-page-header__title {
    font-size: 18px;
    color: #6d737b;
  }

  ::v-deep .el-page-header__title:hover {
    color: #bfc1c4;
  }

  ::v-deep .el-page-header__content {
    font-size: 22px;
    color: #7fabbe;
  }


  .admin-detail {
    display: flex;
    flex-wrap: wrap;
    margin-top: 30px;

    .detail {
      width: 30.3%;
      padding: 5px;
      display: flex;
      margin-bottom: 10px;
      border-bottom: 1px solid #DEDEDE;

      .detail-title {
        width: 120px;
        text-align: right;
        flex-shrink: 0;
        font-size: 18px;
        font-weight: bold;
        letter-spacing: 1px;
      }

      .detail-content {
        flex-grow: 1;
        font-size: 18px;
        letter-spacing: 1px;
      }
    }

    .detail.detail-images {
      width: 100%;
      flex-wrap: wrap;
      display: flex;

      .detail-content {
        width: 70%;
        padding: 0;
        border-radius: 10px;
        border-color: #fff;

        ::v-deep .images_box {
          border-radius: 10px;
          border-color: #fff;
        }

        ::v-deep .uploadImage {
          border-color: #fff;
          border-radius: 5px;

          .el-image__inner {
            border-radius: 5px;
          }
        }
      }
    }

    .detail.detail-editor,
    .detail.detail-dataset {
      width: 100%;
      flex-wrap: wrap;

      .detail-title {
        width: 100%;
        padding: 10px;
        margin-top: 10px;
        background: #659ab1;
        color: #ffffff;
        text-align: left;
        border-radius: 7px;
        letter-spacing: 2px;
      }

      .detail-content {
        padding: 10px;
      }
    }
  }
}
</style>
<script>
import api from '@/api';
import { extend } from '@/utils/extend';


export default {
  data() {
    return {
      loading: false,
      map: {},

    }
  },
  props: {
    id: {
      type: [String, Number],
      required: true
    },
  },
  watch: {
    id: {
      handler() {
        this.loadDetail();
      },
      immediate: true
    }
  },
  computed: {
  },
  methods: {
    goBack() {
      this.$router.go(-1)
    },
    loadDetail() {
      if (this.loading) return;
      this.loading = true;
      this.$get(api.news.detail, {
        id: this.id
      }).then(res => {
        this.loading = false;
        if (res.code == api.code.OK) {
          extend(this, res.data);
        } else {
          this.$message.error(res.msg);
        }
      }).catch(err => {
        this.loading = false;
        this.$message.error(err.message);
      });
    },
  },
  created() {
  },
  mounted() {
  },
  destroyed() {
  }
}
</script>
